package com.balakitbbs.controller;

import org.springframework.beans.factory.annotation.Autowired; 
import java.util.*;               
import org.springframework.stereotype.Controller;               
import org.springframework.web.bind.annotation.PathVariable;               
import org.springframework.web.bind.annotation.RequestMapping;               
import org.springframework.web.servlet.ModelAndView;               
import com.balakitbbs.page.Page;               
import com.balakitbbs.page.SearchPageUtil;               
import com.balakitbbs.service.Bala_messagereadService;
import com.balakitbbs.entity.Bala_messageread;
   /**
    * bala_messageread Controller类
    */ 
@Controller
public class Bala_messagereadController{
	@Autowired
	private Bala_messagereadService bala_messagereadservice;

//增加消息记录表
@RequestMapping("/page/{pageIndex}/{pageSize}/addBala_messageread")
public String addBala_messageread(Bala_messageread bala_messageread,@PathVariable Integer pageIndex,@PathVariable Integer pageSize){
	bala_messageread.setCdate(new Date());
	bala_messageread.setId(UUID.randomUUID().toString());
	bala_messagereadservice.addBala_messageread(bala_messageread);
	return "redirect:/page/"+pageIndex+"/"+pageSize+"/selectBala_messageread.do";
}


//删除消息记录表
@RequestMapping("/page/{Id}/{pageIndex}/{pageSize}/delBala_messageread")
public String delBala_messageread(@PathVariable String Id,@PathVariable Integer pageIndex,@PathVariable Integer pageSize){
	bala_messagereadservice.delBala_messageread(Id);
	return "redirect:/page/"+pageIndex+"/"+pageSize+"/selectBala_messageread.do";
}


//修改消息记录表
@RequestMapping("/page/{pageIndex}/{pageSize}/updateBala_messageread")
public String updateBala_messageread(Bala_messageread bala_messageread,@PathVariable Integer pageIndex,@PathVariable Integer pageSize){
	bala_messageread.setUdate(new Date());
	bala_messagereadservice.updateBala_messageread(bala_messageread);
	return "redirect:/page/"+pageIndex+"/"+pageSize+"/selectBala_messageread.do";
}


//查询消息记录表
@RequestMapping("/page/{pageIndex}/{pageSize}/selectBala_messageread")
public ModelAndView selectBala_messagereads(Bala_messageread bala_messageread,@PathVariable Integer pageIndex,@PathVariable Integer pageSize){
	ModelAndView modelAndView = new ModelAndView();
	int selectBala_messagereadCount = bala_messagereadservice.selectBala_messagereadsByPOJOCount(bala_messageread);
	Page page = new Page(pageIndex, pageSize, selectBala_messagereadCount);
	SearchPageUtil spu = new SearchPageUtil();
	spu.setPage(page);
	modelAndView.addObject("data", bala_messagereadservice.selectBala_messagereadsByPojoPage(spu, bala_messageread));
	modelAndView.addObject("page", page);
	modelAndView.addObject("s", 1);
	modelAndView.addObject("po", new Bala_messageread());
	modelAndView.setViewName("/WEB-INF/page/bala_messageread.jsp");
	return modelAndView;
}

}

